home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10140 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  51 lines

  1. Path: ix.netcom.com!news
  2. From: yurif@ix.netcom.com (Yuri Finkelstein)
  3. Newsgroups: comp.lang.c++
  4. Subject: Can you explain this?
  5. Date: Wed, 06 Mar 1996 08:26:26 GMT
  6. Organization: Netcom
  7. Message-ID: <4hjijm$370@dfw-ixnews1.ix.netcom.com>
  8. NNTP-Posting-Host: srf-ca3-03.ix.netcom.com
  9. X-NETCOM-Date: Wed Mar 06  2:32:54 AM CST 1996
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Can anybody explain why this tiny piece of code doesn't work in CASE1
  13. ( linker error )? Or it's just MSVC 4.0 specific?
  14. Any help will be appreciated.
  15. //--------------------------------------------------------------------------------------
  16. #define CASE1
  17. //#define CASE2
  18. //#define CASE3
  19.  
  20. template <class T> void SetParam( T* pT, int a )
  21. {
  22.     pT->m_a = a;
  23. }
  24.  
  25. class FOO
  26. {
  27.  
  28. #ifdef CASE3
  29. public:
  30. #endif
  31.     int m_a;
  32.  
  33. #ifdef CASE1
  34.     friend void SetParam( FOO* pFOO, int a );
  35. #endif
  36.  
  37. public:
  38.     void Bar( int a ) { SetParam( this, a ); }
  39. }
  40.  
  41. int main()
  42. {
  43.     FOO foo;
  44.     foo.Bar( 5 );
  45.     return 0;
  46. }
  47. ------------------------------------------------
  48. Yuri Finkelstein
  49. (415) 389-0653 (home)
  50.  
  51.